home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
bwtool01.arc
/
POPMENU.SUB
< prev
next >
Wrap
Text File
|
1986-11-29
|
3KB
|
130 lines
'***********************************************************************
SUB POPMENU(HEADER$,CHOICES%,ITEM$(1),FRAME%,FORE%,BACK%,HFORE%,HBACK%,QUADRANT$,SHADOW%,SELECT%) STATIC
DEFINT A-Z
'Determine width of window from length of items
WINDLEN=LEN(HEADER$)
FOR J=1 TO CHOICES
IF LEN(ITEM$(J)) > WINDLEN THEN WINDLEN=LEN(ITEM$(J))
NEXT J
'If Quadrant is in ROW:COL format, extract Row and Column
IF INSTR(QUADRANT$,":")<>0 THEN GOSUB GETORD:GOTO GO1
'Determine Position based on Quadrant Parameter and size of menu
QUADRANT=VAL(QUADRANT$)
IF QUADRANT >4 OR QUADRANT <0 THEN QUADRANT=0
IF QUADRANT=0 THEN CROW=12:CCOL=40 ELSE ON QUADRANT GOSUB QUAD1,QUAD2,QUAD3,QUAD4
ULR=CROW-((CHOICES+2)/2-.5)
ULC=CCOL-((WINDLEN/2)-.5)
LRR=ULR+CHOICES+1
LRC=ULC+WINDLEN-1
GO1: 'Create Window for Menu
CALL MAKEWIND(ULR,ULC,LRR,LRC,FRAME,FORE,BACK,GROW,SHADOW,LABEL$)
'Place Header in Window
TEMPHDR$=SPACE$(WINDLEN)
IF LEN(HEADER$)<> WINDLEN THEN GOSUB PUTHDR
ATTR=(HBACK AND 7)*16+HFORE
ROW=ULR:COL=ULC
CALL FASTPRT(HEADER$,ROW,COL,ATTR)
ATTR=(BACK AND 7)*16+FORE
ROW=ULR+1:COL=ULC
DAT$=STRING$(WINDLEN,205)
CALL FASTPRT(DAT$,ROW,COL,ATTR)
'Place Menu Items in Window
FOR J=1 TO CHOICES
ATTR=(BACK AND 7)*16+FORE
ROW=(ULR+1+J):COL=ULC
DAT$=ITEM$(J)
CALL FASTPRT(DAT$,ROW,COL,ATTR)
NEXT J
'Set current choice to Menu Item #1 and enter Loop
SELECT=1
GOSUB TON
LOOP: GOSUB PROCESS:'Update Position of Selection Marker
GOSUB PRESS:'Get KeyPress
IF KP$=CHR$(13) OR KP$=CHR$(27) THEN GOTO DONE
GOTO LOOP
'Check for KeyPress and sound error if not UP ARROW, DOWN ARROW, or RETURN
PRESS: KP$=INKEY$
IF KP$="" THEN GOTO PRESS
IF KP$=CHR$(13) THEN RETURN
IF KP$=CHR$(27) THEN SELECT=0:RETURN
IF LEN(KP$)=1 THEN SOUND 1000,1:SOUND 1500,2:SOUND 500,1:GOTO PRESS
'Process DOWN ARROW KeyPress
IF ASC(RIGHT$(KP$,1))=80 THEN OLD=SELECT:SELECT=SELECT+1:IF SELECT > CHOICES THEN SELECT=1:RETURN ELSE RETURN
'Process UP ARROW KeyPress
IF ASC(RIGHT$(KP$,1))=72 THEN OLD=SELECT:SELECT=SELECT-1:IF SELECT < 1 THEN SELECT=CHOICES:RETURN ELSE RETURN
'Process ERROR
SOUND 1000,1:SOUND 1500,2:SOUND 500,1:GOTO PRESS
PROCESS:
'Turn off present selection
ATTR=(BACK * 16)+FORE
ROW=(ULR+1+OLD):COL=ULC
DAT$=ITEM$(OLD)
CALL FASTPRT(DAT$,ROW,COL,ATTR)
'Turn on new selection
TON: ATTR=(FORE * 16)+BACK
ROW=(ULR+1+SELECT):COL=ULC
DAT$=ITEM$(SELECT)
CALL FASTPRT(DAT$,ROW,COL,ATTR)
RETURN
QUAD1: CROW=7
CCOL=20
RETURN
QUAD2: CROW=7
CCOL=60
RETURN
QUAD3: CROW=18
CCOL=60
RETURN
QUAD4: CROW=18
CCOL=20
RETURN
GETORD:
ULR=VAL(LEFT$(QUADRANT$,2))+1
ULC=VAL(RIGHT$(QUADRANT$,2))
LRR=ULR+CHOICES+1
LRC=ULC+WINDLEN-1
RETURN
PUTHDR:
PAD=(WINDLEN/2)-(LEN(HEADER$)/2)-.5
MID$(TEMPHDR$,PAD+1,LEN(HEADER$))=HEADER$
HEADER$=TEMPHDR$
RETURN
DONE: END SUB